# 要求对列表使用选择法进行排序
# 排序:默认情况下,按照从小到大进行排序
# 选择排序:
#   假定第一个元素为最大的元素，依次比较其它的元素。如果元素大于该元素，则将其标记为最大元素。
#   找到最大的元素后，将其和最后的元素交换位置
if __name__ == '__main__':
    l = [1, 8, 2, 6, 3, 9, 4, 12, 0, 56, 45]

    # index = 0

    # l [index] > l[1]
    # index = 1

    # l[index] > l[5]
    # index = 5

    # l[index] > l[7]
    # index = 7

    # l[index] > l[9]
    # index = 9

    # length = len(l)
    # for i in range(length):
    #     # print(i)
    #     if l[index] < l[i]:
    #         index = i
    # # print(index)
    # # print(i)
    # l[index], l[i] = l[i], l[index]
    # print(",".join(str(i) for i in l))

    for loop in range(len(l)):
        index = 0
        # loop = 4
        length = len(l) - loop

        for i in range(length):
            # print(i)
            if l[index] < l[i]:
                index = i

        l[index], l[i] = l[i], l[index]
        print(",".join(str(i) for i in l))
